package com.zzy.springbootdemo.design_01_factory.spring.factory;

import com.zzy.springbootdemo.design_01_factory.spring.common.Constants;
import com.zzy.springbootdemo.design_01_factory.spring.service.RewardSpringService;
import com.zzy.springbootdemo.design_01_factory.spring.service.impl.ECardRewardSpringService;
import com.zzy.springbootdemo.design_01_factory.spring.service.impl.MaterialRewardSpringService;
import com.zzy.springbootdemo.design_01_factory.spring.service.impl.VirtualRewardSpringService;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 工厂配置类，主要作用是职责隔离
 */
public class RewardConfig {

    protected static Map<Constants.REWARD, RewardSpringService> factoryMap = new ConcurrentHashMap<>();

    @Resource
    private ECardRewardSpringService eCardRewardSpringService;

    @Resource
    private MaterialRewardSpringService materialRewardSpringService;

    @Resource
    private VirtualRewardSpringService virtualRewardSpringService;

    @PostConstruct
    public void init(){
        factoryMap.put(Constants.REWARD.VIRTUAL_REWORD,virtualRewardSpringService);
        factoryMap.put(Constants.REWARD.MATERIAL_REWOD,materialRewardSpringService);
        factoryMap.put(Constants.REWARD.ECARD_REWORD,eCardRewardSpringService);
    }
}
